import api from '@/api'

const user = {
  namespaced: true,
  state: {
    info: {}
  },
  mutations: {
    SET_USER_INFO (state, payload) {
      state.info = payload
    }
  },
  actions: {
    async getUserInfo ({ commit }) {
      const res = await api.user.info()
      commit('SET_USER_INFO', res.data)
    },
    async loginDo ({ dispatch }, payload) {
      await api.user.login(payload)
      dispatch('getUserInfo')
    }
  },
  modules: {
  }
}

export default user
